import json

import requests

from contant.gaode import *


class GaodePointService:
    @classmethod
    def upload_point(cls, sid: str, tid: str, trid: str, points: list):
        """
        上传轨迹
        :param sid: 服务编码
        :param tid: 终端编码
        :param trid: 高德轨迹编码
        :param points: 轨迹节点信息
        points_list = [{
            "location": "106.551525,29.610642",
            "locatetime": 1714743920000
        }]
        :return: 接口调用结果
        """
        post_data = {
            'key': GAODE_KEY,
            'sid': sid,
            'tid': tid,
            'trid': trid,
            'points': json.dumps(points)
        }
        # 发送HTTP请求
        response = requests.post(GAODE_POINT_UPLOAD, data=post_data)
        # 解析JSON响应
        data = response.json()
        return data
